/*
 * Implement a MyQueue class which implements a queue using two stacks.
 */
package Chapter3;
import Chapter2.Node;

public class Chapter3_5 {
	MyStack stack, reverseStack;
	
	public Chapter3_5(){
		stack = new MyStack();
		reverseStack = new MyStack();
	}
	
	public void enqueue(int value)
	{
		stack.push(value);
	}
	
	public Node dequeue()
	{
		while(stack.top.Next != null){
			reverseStack.push(stack.pop().value);
		}
		Node node = stack.pop();
		while(reverseStack.top != null){
			stack.push(reverseStack.pop().value);
		}
		return node;
	}
	
//	public static void main(String args[])
//	{
//		MyQueue queue = new MyQueue();
//		Chapter3_5 test = new Chapter3_5();
//		for(int i = 0; i < 10; i++)
//		{
//			queue.enqueue(i);
//			test.enqueue(i+1);
//		}
//		Node node1 = queue.dequeue();
//		Node node2 = test.dequeue();
//		System.out.println(node1.value + " " + node2.value);
//	}
}
